<?php

namespace App\Http\Controllers\v1\designPattern\behavioral;

use App\Http\Controllers\Controller;

/**
 * 行为模式之策略模式
 * 客户端
 *
 */
class StrategyClient extends Controller
{
    /**
     * @var PaymentStrategy
     */
    private $paymentType;

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * @param PaymentStrategy $paymentStrategy
     * @return void
     */
    public function setPaymentType(PaymentStrategy $paymentStrategy): void
    {
        $this->paymentType = $paymentStrategy;
    }

    /**
     * @return void
     */
    public function makePay(): void
    {
        /** @var PaymentStrategy $this->paymentType */
        $this->paymentType->pay();
    }

}